<?php
/**
 * 操作日志模型
 * ============================================================================
 * 版权所有 2017 福建华晟网络科技，并保留所有权利。
 * 网站地址: http://www.fldcms.cn
 * ----------------------------------------------------------------------------
 * 这不是一个自由软件！您只能在不用于商业目的的前提下对程序代码进行修改和使用 .
 * 不允许对程序代码以任何形式任何目的的再发布。
 * ============================================================================
 * Author: fld
 * Date: 2017-07-01
 */
namespace app\common\model;
use think\Session;
use think\Request;
class ActionLogModel extends BaseModel {
	private $table_name = 'admin_action_log';
	/**
	 * 获取操作日志列表
	 * @param unknown $result
	 */
    public function getActionLoglist($result){
		$list = $this->select_table_by_page($this->table_name,$result['condition'],'*','id desc',$result['query']);
    	return $list;
    }
    /**
     * 获取操作方法信息
     */
    public function getActionNames(){
    	$action_list = $this->select_table($this->table_name,array(),'distinct(action_name) as action_name');
    	return $action_list;
    }

    /**
     * 操作日志
     * @param string $action_name  操作名
     * @param string $content      操作内容
     */
    public function action_log($action_name,$content){
    	$data = array();
    	$request = Request::instance();
    	$data['admin_id'] = session('admin_id');
    	$data['admin_name'] = session('admin_name');
    	$data['action_ip'] = $request->ip();
    	$data['url'] = $request->controller().'&'.$request->action();
    	$data['content'] = $content;
    	$data['action_name'] = $action_name;
    	$this->add_table($this->table_name,$data);
    }
    
}
